package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.hf.HfFinishOrderRequest;
import com.trhui.mallbook.domain.request.hf.HfWxPayScoreOrderQueryRequest;
import com.trhui.mallbook.domain.request.hf.HfWxPayScoreOrderRequest;
import com.trhui.mallbook.domain.request.hf.HfWxPayScoreOrderRevokedRequest;
import com.trhui.mallbook.domain.response.hf.HfFinishOrderResponse;
import com.trhui.mallbook.domain.response.hf.HfWxPayScoreOrderResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * 微信支付分订单
 *
 * @author: xiaogc
 * @date: 2025/2/13 11:59
 */
public class WxPayScoreOrderClient extends AbstractClient {
    /**
     * 创建微信支付分订单接口
     *
     * @param request
     * @return
     */
    public static BaseResponse<HfWxPayScoreOrderResponse> create(HfWxPayScoreOrderRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.CREATE_WX_PAY_SCORE_ORDER)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfWxPayScoreOrderResponse.class);
    }

    /**
     * 微信支付分完结订单
     */
    public static BaseResponse<HfFinishOrderResponse> finish(HfFinishOrderRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.FINISH_ORDER)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfFinishOrderResponse.class);
    }


    /**
     * 查询微信支付分订单
     */
    public static BaseResponse<HfWxPayScoreOrderResponse> query(HfWxPayScoreOrderQueryRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.QUERY_WX_PAY_SCORE_ORDER)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfWxPayScoreOrderResponse.class);
    }

    /**
     * 取消微信支付分订单
     */
    public static BaseResponse<HfWxPayScoreOrderResponse> revoked(HfWxPayScoreOrderRevokedRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.REVOKED_WX_PAY_SCORE_ORDER)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfWxPayScoreOrderResponse.class);
    }

}
